﻿using Autofac;
using Foundation.Core;

namespace Dyao.Book.Repository.Shared
{
    public class RepositorySharedModule : Module
    {
        protected override void Load(ContainerBuilder containerBuilder)
        {
            var assembly = GetType().Assembly;
            containerBuilder.RegisterAssemblyTypes(assembly)
               .AssignableTo<IScopedDependency>()
               .AsImplementedInterfaces()
               .AsSelf()
               .InstancePerLifetimeScope()
               .PropertiesAutowired();

            containerBuilder.RegisterAssemblyTypes(assembly)
               .AssignableTo<ITransientDependency>()
               .AsImplementedInterfaces()
               .AsSelf()
               .InstancePerDependency()
               .PropertiesAutowired();

            containerBuilder.RegisterAssemblyTypes(assembly)
               .AssignableTo<ISingletonDependency>()
               .AsImplementedInterfaces()
               .AsSelf()
               .SingleInstance()
               .PropertiesAutowired();
        }
    }
}
